a = input()
b = ''
last = ''
for i in a:
    if i in '{[(<':
        b = b + i
    elif i in '}])>':
        last = last + a[-1]
        a = a[:-1]
print(last)
print(b)
for i in range(len(b)):
    if b[i] == '{':
        if last[0] == '}':
            last = last[1:]
    elif b[i] == '[':
        if last[0] == ']':
            last == last[1:]
    elif b[i] == '(':
        if last[0] == ')':
            last = last[1:]
    elif b[i] == '<':
        if last[0] == '>':
            last == last[1:]
if last == '':
    print('True')
else:
    print('False')
    